#ifndef SUNTRACKER_H
#define SUNTRACKER_H

#include "Arduino.h"

#define LDR_UP_A_PIN    1
#define LDR_DOWN_A_PIN  3
#define LDR_LEFT_A_PIN  2
#define LDR_RIGHT_A_PIN 0

// -- INPUT
#define IUP     LDR_UP_A_PIN
#define IDOWN   LDR_DOWN_A_PIN
#define ILEFT   LDR_LEFT_A_PIN
#define IRIGHT  LDR_RIGHT_A_PIN



class Suntracker
{
  public:
    Suntracker();
    void read(int samples, int delayBetweenSamples, boolean calibrateSensor);
    
    int getU() {return ldrU;};
    int getD() {return ldrD;};
    int getL() {return ldrL;};
    int getR() {return ldrR;};
  
    int getPercentU() {return float(ldrU * 100.0) / 1024.0;};
    int getPercentD() {return float(ldrD * 100.0) / 1024.0;};
    int getPercentL() {return float(ldrL * 100.0) / 1024.0;};
    int getPercentR() {return float(ldrR * 100.0) / 1024.0;};

  
    int getUdDelta(){ return (ldrU - ldrD);};
    int getLrDelta(){ return (ldrL - ldrR);}; 


    float getUdRatio(){ return (float(ldrU)/ float(ldrD));};
    float getDuRatio(){ return (float(ldrD)/ float(ldrU));};
    float getLrRatio(){ return (float(ldrL)/ float(ldrR));};
    float getRlRatio(){ return (float(ldrR)/ float(ldrL));};

    int getDeltaThreshold();
    float getRatioThreshold();

    void displayValues();
    
  
  private:
  
    void calibrate();
    int ldrU;
    int ldrD;
    int ldrL;
    int ldrR;
    
    float coefUp;
    float coefDown;
    float coefLeft;
    float coefRight;

};

#endif
